package wpspider.client.view;

import java.awt.Component;
import java.util.HashMap;
import java.util.Map;

/**
 *
 */
public class ComponentRepository {
	/** Singleton instance */
	private static ComponentRepository _instance;
	/** Map for repository */
	private Map _map;
	
	/**
	 * Constructor.
	 */
	private ComponentRepository() {
		_map = new HashMap<String, Component>();
	}

	/**
	 * Gets singleton instance.
	 * @return A instance of this class.
	 */
	public static ComponentRepository getInstance() {
		if(_instance == null) {
			_instance = new ComponentRepository();
		}
		return _instance;
	}
	
	public void setComponent(String name, Component component) {
		component.setName(name);
		_map.put(name, component);
	}
	
	public Component getComponent(String name) {
		return (Component) _map.get(name);
	}
}
